package com.example.wengwyue.patientapplication.activity;

import android.os.Bundle;
import android.view.View;

import com.example.wengwyue.patientapplication.R;
import com.example.wengwyue.patientapplication.utils.helper.VaryViewHelper;


/**
 * 作者： wengwyue   时间： 15/12/1.
 * 功能：
 * 修改：
 */
public abstract class BaseVaryViewActivity extends BaseActivity {
    /**
     * 切换视图的帮助类
     */
    protected VaryViewHelper mVaryViewHelper;
    protected View mErrorView;
    private View mLoadingView;


    @Override
    protected void initView(Bundle savedInstanceState) {
        mErrorView = View.inflate(this, R.layout.layout_error_view, null);
        mLoadingView = View.inflate(this, R.layout.layout_loadingview, null);
        VaryViewHelper.Builder builder = new VaryViewHelper.Builder();
        builder.setDataView(provideDataView());
        builder.setLoadingView(mLoadingView);
        builder.setEmptyView(View.inflate(this, R.layout.layout_empty_view, null));
        builder.setErrorView(mErrorView);
        mErrorView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onReLoad();
            }
        });
        mVaryViewHelper = builder.build();
    }


    protected void onReLoad() {

    }

    /**
     * <p>请提供显示数据的View,比如是一个ListView</p>
     *
     * @return
     */
    public abstract View provideDataView();
}
